package com.tedu.controller;

import com.tedu.entry.Emp;
import com.tedu.service.EmpService;
import com.tedu.service.impl.EmpServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Author：毕龙
 * Date: 2023/7/28 10:28
 */
@WebServlet("/emp/findAll")
public class EmpAllController extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //创建service对象
        EmpService service = new EmpServiceImpl();

        List<Emp> list = service.selectAllEmp();

        request.setAttribute("emps", list);

        //请求转发
        request.getRequestDispatcher("/ems/emp/emplist.jsp").forward(request,response);


    }
}
